/*
 * Manual Drive
 * 
 * The default command for the drivetrain subsystem; this command allows for
 * the manual human control of the robot.
 */

package edu.wpi.first.wpilibj.templates.commands;

import edu.wpi.first.wpilibj.templates.LogitechController;

/**
 *
 * @author Jarrod Risley
 */

public class ManualDrive extends CommandBase {

    /*
     * Global Delcarations
     */
    LogitechController driverController;
    
    public ManualDrive() {
        // Use requires() here to declare subsystem dependencies
        // eg. requires(chassis);
        
        requires(leftDrivetrain);
        requires(rightDrivetrain);
        
        System.out.println("Manual Drive online.");
        
    } // end ExampleCommand

    // Called just before this Command runs the first time
    protected void initialize() {
        
        driverController = oi.getDriverController();
        
    } // end initialize

    // Called repeatedly when this Command is scheduled to run
    protected void execute() {
        
        // Scales the input
        double leftSpeed = driverController.scale(driverController.getLeftY(), 1);
        double rightSpeed = driverController.scale(driverController.getRightY(), 1);
        
        leftDrivetrain.drive(leftSpeed);
        rightDrivetrain.drive(rightSpeed);
        
    } // end execute

    // Make this return true when this Command no longer needs to run execute()
    protected boolean isFinished() {
        return false;
    } // end isFinished

    // Called once after isFinished returns true
    protected void end() {
    } // end end...

    // Called when another command which requires one or more of the same
    // subsystems is scheduled to run
    // Schrodinger's Cat Defalut: interrupted calls end.
    protected void interrupted() {
        end();
    } // end interrupted
    
} // end ManualDrive